package com.store.app.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.store.app.R;
import com.store.app.bean.BookedBean;
import com.store.app.bean.WypGoodsBean;

import java.util.List;

/**
 * Created by liuwy on 2016/2/19.
 */
public class Confirpay_RecyclerAdapter extends RecyclerView.Adapter<Confirpay_RecyclerAdapter.ViewHolder> {


    private List<WypGoodsBean> bookedBeanList;

    private Context context;

    private LayoutInflater mInflater;

    public Confirpay_RecyclerAdapter(List<WypGoodsBean> bookedBeanList, Context context) {
        this.bookedBeanList = bookedBeanList;
        this.context = context;
        mInflater = LayoutInflater.from(context);
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_confim_recycler,
                parent, false);
        ViewHolder viewHolder = null;
        viewHolder = new ViewHolder(view);

        viewHolder.ivService = (ImageView) view.findViewById(R.id.item_conffim_recycler_img);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        WypGoodsBean serviceBean = bookedBeanList.get(position);
        ImageLoader.getInstance().displayImage(serviceBean.getPic_show_url(), holder.ivService, options);
    }


    @Override
    public int getItemCount() {
        return bookedBeanList == null ? 0 : bookedBeanList.size();
    }



    public static class ViewHolder extends RecyclerView.ViewHolder {
        public ViewHolder(View arg0) {
            super(arg0);
        }

        ImageView ivService;
        TextView tvName;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .showImageOnLoading(R.drawable.default_picture_s)
            .showImageOnFail(R.drawable.default_picture_s)
            .showStubImage(R.drawable.default_picture_s)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
}
